home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / mac / data / menu_dvd.swf / scripts / __Packages / mx / core / UIObject.as < prev   
Text File  |  2007-11-07  |  15KB  |  600 lines

  1. class mx.core.UIObject extends MovieClip
  2. {
  3.    static var symbolName = "UIObject";
  4.    static var symbolOwner = mx.core.UIObject;
  5.    static var version = "2.0.2.126";
  6.    static var textColorList = {color:1,disabledColor:1};
  7.    var invalidateFlag = false;
  8.    var lineWidth = 1;
  9.    var lineColor = 0;
  10.    var tabEnabled = false;
  11.    var clipParameters = {visible:1,minHeight:1,minWidth:1,maxHeight:1,maxWidth:1,preferredHeight:1,preferredWidth:1};
  12.    function UIObject()
  13.    {
  14.       super();
  15.       this.constructObject();
  16.    }
  17.    function get width()
  18.    {
  19.       return this._width;
  20.    }
  21.    function get height()
  22.    {
  23.       return this._height;
  24.    }
  25.    function get left()
  26.    {
  27.       return this._x;
  28.    }
  29.    function get x()
  30.    {
  31.       return this._x;
  32.    }
  33.    function get top()
  34.    {
  35.       return this._y;
  36.    }
  37.    function get y()
  38.    {
  39.       return this._y;
  40.    }
  41.    function get right()
  42.    {
  43.       return this._parent.width - (this._x + this.__get__width());
  44.    }
  45.    function get bottom()
  46.    {
  47.       return this._parent.height - (this._y + this.__get__height());
  48.    }
  49.    function getMinHeight(Void)
  50.    {
  51.       return this._minHeight;
  52.    }
  53.    function setMinHeight(h)
  54.    {
  55.       this._minHeight = h;
  56.    }
  57.    function get minHeight()
  58.    {
  59.       return this.getMinHeight();
  60.    }
  61.    function set minHeight(h)
  62.    {
  63.       this.setMinHeight(h);
  64.    }
  65.    function getMinWidth(Void)
  66.    {
  67.       return this._minWidth;
  68.    }
  69.    function setMinWidth(w)
  70.    {
  71.       this._minWidth = w;
  72.    }
  73.    function get minWidth()
  74.    {
  75.       return this.getMinWidth();
  76.    }
  77.    function set minWidth(w)
  78.    {
  79.       this.setMinWidth(w);
  80.    }
  81.    function setVisible(x, noEvent)
  82.    {
  83.       if(x != this._visible)
  84.       {
  85.          this._visible = x;
  86.          if(noEvent != true)
  87.          {
  88.             this.dispatchEvent({type:(!x ? "hide" : "reveal")});
  89.          }
  90.       }
  91.    }
  92.    function get visible()
  93.    {
  94.       return this._visible;
  95.    }
  96.    function set visible(x)
  97.    {
  98.       this.setVisible(x,false);
  99.    }
  100.    function get scaleX()
  101.    {
  102.       return this._xscale;
  103.    }
  104.    function set scaleX(x)
  105.    {
  106.       this._xscale = x;
  107.    }
  108.    function get scaleY()
  109.    {
  110.       return this._yscale;
  111.    }
  112.    function set scaleY(y)
  113.    {
  114.       this._yscale = y;
  115.    }
  116.    function doLater(obj, fn)
  117.    {
  118.       if(this.methodTable == undefined)
  119.       {
  120.          this.methodTable = new Array();
  121.       }
  122.       this.methodTable.push({obj:obj,fn:fn});
  123.       this.onEnterFrame = this.doLaterDispatcher;
  124.    }
  125.    function doLaterDispatcher(Void)
  126.    {
  127.       delete this.onEnterFrame;
  128.       if(this.invalidateFlag)
  129.       {
  130.          this.redraw();
  131.       }
  132.       var __methodTable = this.methodTable;
  133.       this.methodTable = new Array();
  134.       if(__methodTable.length > 0)
  135.       {
  136.          var m;
  137.          while((m = __methodTable.shift()) != undefined)
  138.          {
  139.             m.obj[m.fn]();
  140.          }
  141.       }
  142.    }
  143.    function cancelAllDoLaters(Void)
  144.    {
  145.       delete this.onEnterFrame;
  146.       this.methodTable = new Array();
  147.    }
  148.    function invalidate(Void)
  149.    {
  150.       this.invalidateFlag = true;
  151.       this.onEnterFrame = this.doLaterDispatcher;
  152.    }
  153.    function invalidateStyle(Void)
  154.    {
  155.       this.invalidate();
  156.    }
  157.    function redraw(bAlways)
  158.    {
  159.       if(this.invalidateFlag || bAlways)
  160.       {
  161.          this.invalidateFlag = false;
  162.          var i;
  163.          for(i in this.tfList)
  164.          {
  165.             this.tfList[i].draw();
  166.          }
  167.          this.draw();
  168.          this.dispatchEvent({type:"draw"});
  169.       }
  170.    }
  171.    function draw(Void)
  172.    {
  173.    }
  174.    function move(x, y, noEvent)
  175.    {
  176.       var oldX = this._x;
  177.       var oldY = this._y;
  178.       this._x = x;
  179.       this._y = y;
  180.       if(noEvent != true)
  181.       {
  182.          this.dispatchEvent({type:"move",oldX:oldX,oldY:oldY});
  183.       }
  184.    }
  185.    function setSize(w, h, noEvent)
  186.    {
  187.       var oldWidth = this.__width;
  188.       var oldHeight = this.__height;
  189.       this.__width = w;
  190.       this.__height = h;
  191.       this.size();
  192.       if(noEvent != true)
  193.       {
  194.          this.dispatchEvent({type:"resize",oldWidth:oldWidth,oldHeight:oldHeight});
  195.       }
  196.    }
  197.    function size(Void)
  198.    {
  199.       this._width = this.__width;
  200.       this._height = this.__height;
  201.    }
  202.    function drawRect(x1, y1, x2, y2)
  203.    {
  204.       this.moveTo(x1,y1);
  205.       this.lineTo(x2,y1);
  206.       this.lineTo(x2,y2);
  207.       this.lineTo(x1,y2);
  208.       this.lineTo(x1,y1);
  209.    }
  210.    function createLabel(name, depth, text)
  211.    {
  212.       this.createTextField(name,depth,0,0,0,0);
  213.       var o = this[name];
  214.       o._color = mx.core.UIObject.textColorList;
  215.       o._visible = false;
  216.       o.__text = text;
  217.       if(this.tfList == undefined)
  218.       {
  219.          this.tfList = new Object();
  220.       }
  221.       this.tfList[name] = o;
  222.       o.invalidateStyle();
  223.       this.invalidate();
  224.       o.styleName = this;
  225.       return o;
  226.    }
  227.    function createObject(linkageName, id, depth, initobj)
  228.    {
  229.       return this.attachMovie(linkageName,id,depth,initobj);
  230.    }
  231.    function createClassObject(className, id, depth, initobj)
  232.    {
  233.       var bSubClass = className.symbolName == undefined;
  234.       if(bSubClass)
  235.       {
  236.          Object.registerClass(className.symbolOwner.symbolName,className);
  237.       }
  238.       var o = mx.core.UIObject(this.createObject(className.symbolOwner.symbolName,id,depth,initobj));
  239.       if(bSubClass)
  240.       {
  241.          Object.registerClass(className.symbolOwner.symbolName,className.symbolOwner);
  242.       }
  243.       return o;
  244.    }
  245.    function createEmptyObject(id, depth)
  246.    {
  247.       return this.createClassObject(mx.core.UIObject,id,depth);
  248.    }
  249.    function destroyObject(id)
  250.    {
  251.       var o = this[id];
  252.       if(o.getDepth() < 0)
  253.       {
  254.          var dt = this.buildDepthTable();
  255.          var i = this.findNextAvailableDepth(0,dt,"up");
  256.          var temp = i;
  257.          o.swapDepths(temp);
  258.       }
  259.       o.removeMovieClip();
  260.       delete this[id];
  261.    }
  262.    function getSkinIDName(tag)
  263.    {
  264.       return this.idNames[tag];
  265.    }
  266.    function setSkin(tag, linkageName, initObj)
  267.    {
  268.       if(_global.skinRegistry[linkageName] == undefined)
  269.       {
  270.          mx.skins.SkinElement.registerElement(linkageName,mx.skins.SkinElement);
  271.       }
  272.       return this.createObject(linkageName,this.getSkinIDName(tag),tag,initObj);
  273.    }
  274.    function createSkin(tag)
  275.    {
  276.       var id = this.getSkinIDName(tag);
  277.       this.createEmptyObject(id,tag);
  278.       return this[id];
  279.    }
  280.    function createChildren(Void)
  281.    {
  282.    }
  283.    function _createChildren(Void)
  284.    {
  285.       this.createChildren();
  286.       this.childrenCreated = true;
  287.    }
  288.    function constructObject(Void)
  289.    {
  290.       if(this._name == undefined)
  291.       {
  292.          return undefined;
  293.       }
  294.       this.init();
  295.       this._createChildren();
  296.       this.createAccessibilityImplementation();
  297.       this._endInit();
  298.       if(this.validateNow)
  299.       {
  300.          this.redraw(true);
  301.       }
  302.       else
  303.       {
  304.          this.invalidate();
  305.       }
  306.    }
  307.    function initFromClipParameters(Void)
  308.    {
  309.       var bFound = false;
  310.       var i;
  311.       for(i in this.clipParameters)
  312.       {
  313.          if(this.hasOwnProperty(i))
  314.          {
  315.             bFound = true;
  316.             this["def_" + i] = this[i];
  317.             delete this[i];
  318.          }
  319.       }
  320.       if(bFound)
  321.       {
  322.          for(i in this.clipParameters)
  323.          {
  324.             var v = this["def_" + i];
  325.             if(v != undefined)
  326.             {
  327.                this[i] = v;
  328.             }
  329.          }
  330.       }
  331.    }
  332.    function init(Void)
  333.    {
  334.       this.__width = this._width;
  335.       this.__height = this._height;
  336.       if(this.initProperties == undefined)
  337.       {
  338.          this.initFromClipParameters();
  339.       }
  340.       else
  341.       {
  342.          this.initProperties();
  343.       }
  344.       if(_global.cascadingStyles == true)
  345.       {
  346.          this.stylecache = new Object();
  347.       }
  348.    }
  349.    function getClassStyleDeclaration(Void)
  350.    {
  351.       var o = this;
  352.       var c = this.className;
  353.       while(c != undefined)
  354.       {
  355.          if(this.ignoreClassStyleDeclaration[c] == undefined)
  356.          {
  357.             if(_global.styles[c] != undefined)
  358.             {
  359.                return _global.styles[c];
  360.             }
  361.          }
  362.          o = o.__proto__;
  363.          c = o.className;
  364.       }
  365.    }
  366.    function setColor(color)
  367.    {
  368.    }
  369.    function __getTextFormat(tf, bAll)
  370.    {
  371.       var o = this.stylecache.tf;
  372.       if(o != undefined)
  373.       {
  374.          var j;
  375.          for(j in mx.styles.StyleManager.TextFormatStyleProps)
  376.          {
  377.             if(bAll || mx.styles.StyleManager.TextFormatStyleProps[j])
  378.             {
  379.                if(tf[j] == undefined)
  380.                {
  381.                   tf[j] = o[j];
  382.                }
  383.             }
  384.          }
  385.          return false;
  386.       }
  387.       var bUndefined = false;
  388.       var j;
  389.       for(j in mx.styles.StyleManager.TextFormatStyleProps)
  390.       {
  391.          if(bAll || mx.styles.StyleManager.TextFormatStyleProps[j])
  392.          {
  393.             if(tf[j] == undefined)
  394.             {
  395.                var v = this._tf[j];
  396.                if(v != undefined)
  397.                {
  398.                   tf[j] = v;
  399.                }
  400.                else if(j == "font" && this.fontFamily != undefined)
  401.                {
  402.                   tf[j] = this.fontFamily;
  403.                }
  404.                else if(j == "size" && this.fontSize != undefined)
  405.                {
  406.                   tf[j] = this.fontSize;
  407.                }
  408.                else if(j == "color" && this.color != undefined)
  409.                {
  410.                   tf[j] = this.color;
  411.                }
  412.                else if(j == "leftMargin" && this.marginLeft != undefined)
  413.                {
  414.                   tf[j] = this.marginLeft;
  415.                }
  416.                else if(j == "rightMargin" && this.marginRight != undefined)
  417.                {
  418.                   tf[j] = this.marginRight;
  419.                }
  420.                else if(j == "italic" && this.fontStyle != undefined)
  421.                {
  422.                   tf[j] = this.fontStyle == j;
  423.                }
  424.                else if(j == "bold" && this.fontWeight != undefined)
  425.                {
  426.                   tf[j] = this.fontWeight == j;
  427.                }
  428.                else if(j == "align" && this.textAlign != undefined)
  429.                {
  430.                   tf[j] = this.textAlign;
  431.                }
  432.                else if(j == "indent" && this.textIndent != undefined)
  433.                {
  434.                   tf[j] = this.textIndent;
  435.                }
  436.                else if(j == "underline" && this.textDecoration != undefined)
  437.                {
  438.                   tf[j] = this.textDecoration == j;
  439.                }
  440.                else if(j == "embedFonts" && this.embedFonts != undefined)
  441.                {
  442.                   tf[j] = this.embedFonts;
  443.                }
  444.                else
  445.                {
  446.                   bUndefined = true;
  447.                }
  448.             }
  449.          }
  450.       }
  451.       if(bUndefined)
  452.       {
  453.          var name = this.styleName;
  454.          if(name != undefined)
  455.          {
  456.             if(typeof name != "string")
  457.             {
  458.                bUndefined = name.__getTextFormat(tf,true,this);
  459.             }
  460.             else if(_global.styles[name] != undefined)
  461.             {
  462.                bUndefined = _global.styles[name].__getTextFormat(tf,true,this);
  463.             }
  464.          }
  465.       }
  466.       if(bUndefined)
  467.       {
  468.          var ss = this.getClassStyleDeclaration();
  469.          if(ss != undefined)
  470.          {
  471.             bUndefined = ss.__getTextFormat(tf,true,this);
  472.          }
  473.       }
  474.       if(bUndefined)
  475.       {
  476.          if(_global.cascadingStyles)
  477.          {
  478.             if(this._parent != undefined)
  479.             {
  480.                bUndefined = this._parent.__getTextFormat(tf,false);
  481.             }
  482.          }
  483.       }
  484.       if(bUndefined)
  485.       {
  486.          bUndefined = _global.style.__getTextFormat(tf,true,this);
  487.       }
  488.       return bUndefined;
  489.    }
  490.    function _getTextFormat(Void)
  491.    {
  492.       var tf = this.stylecache.tf;
  493.       if(tf != undefined)
  494.       {
  495.          return tf;
  496.       }
  497.       tf = new TextFormat();
  498.       this.__getTextFormat(tf,true);
  499.       this.stylecache.tf = tf;
  500.       if(this.enabled == false)
  501.       {
  502.          var c = this.getStyle("disabledColor");
  503.          tf.color = c;
  504.       }
  505.       return tf;
  506.    }
  507.    function getStyleName(Void)
  508.    {
  509.       var name = this.styleName;
  510.       if(name != undefined)
  511.       {
  512.          if(typeof name != "string")
  513.          {
  514.             return name.getStyleName();
  515.          }
  516.          return name;
  517.       }
  518.       if(this._parent != undefined)
  519.       {
  520.          return this._parent.getStyleName();
  521.       }
  522.       return undefined;
  523.    }
  524.    function getStyle(styleProp)
  525.    {
  526.       var v = undefined;
  527.       _global.getStyleCounter++;
  528.       if(this[styleProp] != undefined)
  529.       {
  530.          return this[styleProp];
  531.       }
  532.       var name = this.styleName;
  533.       if(name != undefined)
  534.       {
  535.          if(typeof name != "string")
  536.          {
  537.             v = name.getStyle(styleProp);
  538.          }
  539.          else
  540.          {
  541.             var ss = _global.styles[name];
  542.             v = ss.getStyle(styleProp);
  543.          }
  544.       }
  545.       if(v != undefined)
  546.       {
  547.          return v;
  548.       }
  549.       var ss = this.getClassStyleDeclaration();
  550.       if(ss != undefined)
  551.       {
  552.          v = ss[styleProp];
  553.       }
  554.       if(v != undefined)
  555.       {
  556.          return v;
  557.       }
  558.       if(_global.cascadingStyles)
  559.       {
  560.          if(mx.styles.StyleManager.isInheritingStyle(styleProp) || mx.styles.StyleManager.isColorStyle(styleProp))
  561.          {
  562.             var b = this.stylecache;
  563.             if(b != undefined)
  564.             {
  565.                if(b[styleProp] != undefined)
  566.                {
  567.                   return b[styleProp];
  568.                }
  569.             }
  570.             if(this._parent != undefined)
  571.             {
  572.                v = this._parent.getStyle(styleProp);
  573.             }
  574.             else
  575.             {
  576.                v = _global.style[styleProp];
  577.             }
  578.             if(b != undefined)
  579.             {
  580.                b[styleProp] = v;
  581.             }
  582.             return v;
  583.          }
  584.       }
  585.       if(v == undefined)
  586.       {
  587.          v = _global.style[styleProp];
  588.       }
  589.       return v;
  590.    }
  591.    static function mergeClipParameters(o, p)
  592.    {
  593.       for(var i in p)
  594.       {
  595.          o[i] = p[i];
  596.       }
  597.       return true;
  598.    }
  599. }
  600.